package com.tansun.easycare.rule.referencedata.service;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.tansun.easycare.rule.common.entity.RuleBaseEntity;
import com.tansun.easycare.rule.common.service.RuleBaseService;
import com.tansun.easycare.rule.datamodel.entity.RuleDataparams;
import com.tansun.easycare.rule.exception.BizException;
import com.tansun.easycare.rule.referencedata.entity.RuleReferenceData;
import com.tansun.easycare.rule.ruleflow.entity.RuleFlowRects;
import com.tansun.easycare.rule.rulemange.entity.RuleManage;
import com.tansun.easycare.rule.table.entity.RuleDecisiontableDetail;

public interface RuleReferenceDataService extends RuleBaseService<RuleReferenceData> {

    /**
     * 收集表明细信息
     */
    void collectTableDetail(RuleDecisiontableDetail decisiontableDetail, Map<String, RuleReferenceData> map, RuleManage ruleManage)
            throws BizException;

    /**
     * 保存数据引用
     */
    void saveReferenceData(Map<String, RuleReferenceData> map) throws BizException;

    void saveReferenceDataFuncRef(List<RuleDataparams> ruleParamdatas,RuleManage ruleManage) throws BizException;
    
    void findFuncReferenceDataList(RuleManage ruleManage, Collection<RuleReferenceData> refList,String type) throws BizException;
    /**
     *
     * @param referenceData
     * @return
     */
    Collection<RuleReferenceData> findReferenceDataList(RuleReferenceData referenceData);

    void findFuncReferenceDataList(RuleManage ruleManage, Collection<RuleReferenceData> refList)  throws BizException;
    /**
     * 收集数据信息
     */
    void collectCommonData(RuleBaseEntity dataEntity, String key, String contentType, RuleManage ruleManage, Map<String, RuleReferenceData> map) throws BizException;

    /**
     * 去重引用数据
     */
    Collection<RuleReferenceData> reDataModeRef(List<RuleReferenceData> list);
    /**
     * 递归查找关联数据
     * @param projectCode 项目编码
     * @param code 编码
     * @param type 类型
     * @param version 版本
     * @param refList 存储目标
     * @param listFlag 标志list 存储code，防止无限循环，传值为null
     */
    void findReferenceDataList(String projectCode, String code, String type, String version, String contentType, Collection<RuleReferenceData> refList,List<String> listFlag);

    void collectCommonData(RuleReferenceData ruleReferenceData, String key, String contentType, RuleManage ruleManage, Map<String, RuleReferenceData> map) throws BizException;
    /**
     * 从MAP中获取参数信息
     * @param dataMap
     * @param key
     * @param contentType
     * @param ruleManage
     * @param map
     * @throws BizException
     */
    public void collectFromMap(Map<String, String> dataMap, String key, String contentType, RuleManage ruleManage, Map<String, RuleReferenceData> map) throws BizException;
    
    /**
     * 
     * 从公式中收集引用数据
     */
    public void collectFromFormula(String formula, RuleManage ruleManage, Map<String, RuleReferenceData> map) throws BizException;
    
    
    /*判断是否被引用*/
    List<RuleReferenceData>  findReferenceParamList(RuleReferenceData referenceData);
    /**
     * 查找是否冠军挑战者模式
     */
	Collection<RuleReferenceData> findReferenceChampionList(RuleFlowRects flowRectsInfo);
	
	
	List<RuleReferenceData>   findModelReferenceList(Map<String,Object> map);
	
	void deleteByManage(RuleReferenceData arg0);
	
    /**
     * 根据 函数变量查找其应用的函数变量
     */
    void findFuncReferenceDataList(String projectCode,String className,String name, Collection<RuleReferenceData> refList) throws BizException;

	/**
	 * 关联数据复制
	 * @param ruleManageOld
	 * @param ruleManageNew
	 */
	public void copyReferenceData(RuleManage ruleManageOld,RuleManage ruleManageNew);
	
    void deleteByMutilVersion(RuleManage ruleManage, List<String> versions);
    
    
    List<RuleReferenceData>  findReferenceModelList(RuleReferenceData referenceData);
}
